from datetime import timezone

from django.contrib.auth.hashers import check_password
from django.db import models
from django.db import models


# from Student.models import Student


# 学校模型
class School(models.Model):
    # 学校名称
    name = models.CharField(max_length=100, null=False)
    # 学校地址
    address = models.CharField(max_length=200, null=False,blank=False),
    # 邮箱
    email = models.CharField(max_length=100)
    # 照片
    image = models.CharField(max_length=200, null=True)
    # 账号字段
    account = models.CharField(max_length=100)
    # 密码字段
    password = models.CharField(max_length=100)

    ismanager = models.BooleanField(default=False)

    # __str__方法返回学校名称
    def __str__(self):
        return self.name


class Snotification(models.Model):
    school = models.ForeignKey(School, on_delete=models.CASCADE)
    title = models.CharField(max_length=100)
    content = models.TextField()
    created_at = models.DateTimeField(auto_now_add=True)
    img = models.CharField(max_length=200, null=True)

    class Meta:
        verbose_name_plural = "学校公告"
        ordering = ['-created_at']

    def __str__(self):
        return f"{self.school.name}的公告"


class SchoolApplication(models.Model):
    school_name = models.CharField(max_length=100, null=False)
    address = models.CharField(max_length=200)
    email = models.CharField(max_length=100)
    image = models.CharField(max_length=200, null=True)
    date_joined = models.DateTimeField(auto_now_add=True)
    mobile = models.CharField(max_length=20)
    status = models.CharField(max_length=100, null=True,
                              choices=[('待审核', '待审核'), ('通过', '通过'), ('拒绝', '拒绝')])
    type = models.CharField(max_length=100, null=True,)

    class Meta:
        verbose_name_plural = "学校账号申请"
        ordering = ['-date_joined']

    def __str__(self):
        return f"{self.school_name}的账号申请"
